Skip to content

Fix containerized .NET project creation failing with exit code 73#4956

Merged
nturinski merged 3 commits intomainfrom
fix/containerized-dotnet-force-overwrite
Apr 1, 2026
Merged

Fix containerized .NET project creation failing with exit code 73#4956
nturinski merged 3 commits intomainfrom
fix/containerized-dotnet-force-overwrite

Conversation

@alexweininger
Copy link
Copy Markdown
Member

Problem

When creating a containerized .NET project, func init runs first and creates files (.gitignore, .csproj, Program.cs, host.json, local.settings.json, launchSettings.json). The subsequent dotnet new func command then fails with exit code 73 because those files already exist.

Fix

Pass --force to the dotnet new command when creating containerized projects, so it overwrites the files created by the preceding func init step.

Changes

  • executeDotnetTemplateCommand.ts — Added optional options?: { force?: boolean } parameter to executeDotnetTemplateCreate() and appends --force to args when set.
  • DotnetProjectCreateStep.ts — Passes { force: true } when context.containerizedProject is truthy.

Fixes #4955

When creating a containerized .NET project, `func init` runs first and
creates files (.gitignore, .csproj, Program.cs, host.json, etc.). The
subsequent `dotnet new func` command then fails with exit code 73
because those files already exist.

Pass `--force` to `dotnet new` when creating containerized projects so
it overwrites the files created by the preceding `func init` step.

Fixes #4955

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 1, 2026 15:55
@alexweininger alexweininger requested a review from a team as a code owner April 1, 2026 15:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes containerized C#/.NET project creation by ensuring the dotnet new template invocation can overwrite files created earlier by func init --docker, avoiding failures like exit code 73.

Changes:

  • Extend executeDotnetTemplateCreate with an optional { force?: boolean } and add --force when enabled.
  • Enable force when creating containerized .NET projects in DotnetProjectCreateStep.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/templates/dotnet/executeDotnetTemplateCommand.ts Adds support for optionally appending --force to dotnet new creation args.
src/commands/createNewProject/ProjectCreateStep/DotnetProjectCreateStep.ts Passes { force: true } for containerized project creation to prevent file-exists failures.

}

await executeDotnetTemplateCreate(context, version, projTemplateKey, context.projectPath, identity, templateArgs);
await executeDotnetTemplateCreate(context, version, projTemplateKey, context.projectPath, identity, templateArgs, { force: !!context.containerizedProject });
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the non-containerized path, confirmOverwriteExisting prompts the user about overwriting existing files, but the subsequent dotnet new invocation will still refuse to overwrite on collisions unless --force is passed. Since executeDotnetTemplateCreate now supports force, consider wiring the prompt result (or presence of conflicts) into this call so the UX matches the actual behavior (or otherwise clarify that the prompt is informational only).

Copilot uses AI. Check for mistakes.
Comment thread src/templates/dotnet/executeDotnetTemplateCommand.ts Outdated
- Use withFlagArg('--force', ...) instead of withArg('--force') as it
  is purpose-built for boolean flags.
- Always pass force: true since the non-containerized path already
  prompts the user via confirmOverwriteExisting before reaching
  dotnet new, so --force is needed to match the confirmed intent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@alexweininger alexweininger enabled auto-merge (squash) April 1, 2026 16:26
@alexweininger alexweininger disabled auto-merge April 1, 2026 16:32
@nturinski nturinski merged commit 57d1500 into main Apr 1, 2026
2 checks passed
@nturinski nturinski deleted the fix/containerized-dotnet-force-overwrite branch April 1, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail to create a C# containerized project

4 participants